PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.2.2
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.2.2
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / frontend / src / common / angular-chosen.directive.js
wp-all-export / frontend / src / common Last commit date
mapping 7 years ago angular-chosen.directive.js 7 years ago attributes.service.js 7 years ago autodetect.directive.js 7 years ago cascade.directive.js 7 years ago contenteditable.directive.js 7 years ago currency.service.js 7 years ago droppable.directive.js 7 years ago export.service.js 7 years ago focusMeWhenEnabled.directive.js 7 years ago googleCategoriesService.js 7 years ago main.controller.js 7 years ago styledInput.directive.js 7 years ago template.service.js 7 years ago tipsy.directive.js 7 years ago wpHttp.service.js 7 years ago
angular-chosen.directive.js
110 lines
1 function chosen($timeout) {
2 var EVENTS, scope, linker, watchCollection;
3
4 /*
5 * List of events and the alias used for binding with angularJS
6 */
7 EVENTS = [{
8 onChange: 'change'
9 }, {
10 onReady: 'chosen:ready'
11 }, {
12 onMaxSelected: 'chosen:maxselected'
13 }, {
14 onShowDropdown: 'chosen:showing_dropdown'
15 }, {
16 onHideDropdown: 'chosen:hiding_dropdown'
17 }, {
18 onNoResult: 'chosen:no_results'
19 }];
20
21 /*
22 * Items to be added in the scope of the directive
23 */
24 scope = {
25 options: '=', // the options array
26 ngModel: '=', // the model to bind to,,
27 ngDisabled: '='
28 };
29
30 /*
31 * initialize the list of items
32 * to watch to trigger the chosen:updated event
33 */
34 watchCollection = [];
35 Object.keys(scope).forEach(function (scopeName) {
36 watchCollection.push(scopeName);
37 });
38
39 /*
40 * Add the list of event handler of the chosen
41 * in the scope.
42 */
43 EVENTS.forEach(function (event) {
44 var eventNameAlias = Object.keys(event)[0];
45 scope[eventNameAlias] = '=';
46 });
47
48 /* Linker for the directive */
49 linker = function ($scope, iElm, iAttr) {
50 var maxSelection = parseInt(iAttr.maxSelection, 10),
51 searchThreshold = parseInt(iAttr.searchThreshold, 10);
52
53 if (isNaN(maxSelection) || maxSelection === Infinity) {
54 maxSelection = undefined;
55 }
56
57 if (isNaN(searchThreshold) || searchThreshold === Infinity) {
58 searchThreshold = undefined;
59 }
60
61 var allowSingleDeselect = iElm.attr('allow-single-deselect') !== undefined ? true : false;
62 var noResultsText = iElm.attr('no-results-text') !== undefined ? iAttr.noResultsText : "No results found.";
63
64 iElm.chosen({
65 width: '100%',
66 max_selected_options: maxSelection,
67 disable_search_threshold: searchThreshold,
68 search_contains: true,
69 allow_single_deselect: allowSingleDeselect,
70 no_results_text: noResultsText
71 });
72
73 iElm.on('change', function () {
74 iElm.trigger('chosen:updated');
75 });
76
77 $scope.$watchGroup(watchCollection, function () {
78 $timeout(function () {
79 iElm.trigger('chosen:updated');
80 }, 100);
81 });
82
83 $scope.$on('chosen:updated', function() {
84 iElm.trigger('chosen:updated');
85 });
86
87 // assign event handlers
88 EVENTS.forEach(function (event) {
89 var eventNameAlias = Object.keys(event)[0];
90
91 if (typeof $scope[eventNameAlias] === 'function') { // check if the handler is a function
92 iElm.on(event[eventNameAlias], function (event) {
93 $scope.$apply(function () {
94 $scope[eventNameAlias](event);
95 });
96 }); // listen to the event triggered by chosen
97 }
98 });
99 };
100
101 // return the directive
102 return {
103 name: 'chosen',
104 scope: scope,
105 restrict: 'A',
106 link: linker
107 };
108 }
109
110 GoogleMerchants.directive('chosen', ['$timeout', chosen]);