PageSourceSearch

https://app.menucontrol.com.br/directives/bootstrapToggle/bootstrapToggle.js

js menucontrol.com.br collected 2026-10-05 23:46:06 UTC 1,287 bytes, 55 lines download raw bytes

1"use strict"
2
3/**
4 * Bootstrap-toggle Directive
5 * @link https://github.com/minhur/bootstrap-toggle
6 */
7angular.module("toggleCheckbox", []).directive("toggleCheckbox", function() {
8  /**
9   * Directive
10   */
11  return {
12    restrict: "A",
13    transclude: true,
14    replace: false,
15    require: "ngModel",
16    link: function($scope, $element, $attr, require) {
17      var ngModel = require
18
19      // update model from Element
20      var updateModelFromElement = function() {
21        // If modified
22        var checked = $element.prop("checked")
23        if (checked != ngModel.$viewValue) {
24          // Update ngModel
25          ngModel.$setViewValue(checked)
26          $scope.$apply()
27        }
28      }
29
30      // Update input from Model
31      var updateElementFromModel = function() {
32        // Update button state to match model
33        $element.trigger("change")
34      }
35
36      // Observe: Element changes affect Model
37      $element.on("change", function() {
38        updateModelFromElement()
39      })
40
41      // Observe: ngModel for changes
42      $scope.$watch(
43        function() {
44          return ngModel.$viewValue
45        },
46        function() {
47          updateElementFromModel()
48        }
49      )
50
51      // Initialise BootstrapToggle
52      $element.bootstrapToggle()
53    }
54  }
55})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.